#include "SpriteDonkeyKong.h"
#include <sstream>

SpriteDonkeyKong::SpriteDonkeyKong(CL_GraphicContext gc)
{
	donkeyKongContext = gc;
	for(int h=0;h<FRAMES_DONKEYKONG;h++){
		donkeyKongResources[h]=NULL;
	}
	donkeyKongResources[0]= new CL_ResourceManager("DonkeyStanding.xml");
	donkeyKongResources[1]= new CL_ResourceManager("DonkeyThrowing.xml");
	for(int i=0;i<FRAMES_DONKEYKONG;i++){
		donkeyKongSprites[i]=NULL;
	}
	donkeyKongSprites[0]=new CL_Sprite(gc, "DonkeyStanding", donkeyKongResources[0]);
	donkeyKongSprites[1]=new CL_Sprite(gc, "DonkeyThrowing", donkeyKongResources[1]);

}

void SpriteDonkeyKong::drawfixedstandingdonkey(CL_Vec2<int> position)
{
	donkeyKongSprites[0]->draw(donkeyKongContext, position.x, position.y);
}

void SpriteDonkeyKong::drawthrowingdonkey(CL_Vec2<int> position)
{
	donkeyKongSprites[1]->draw(donkeyKongContext, position.x, position.y);
}

void SpriteDonkeyKong::drawpoints(int score)
{
	std::stringstream out;
	out<<"SCORE: ";
	out<<score;
	CL_FontDescription font_desc;
	font_desc.set_typeface_name("Arial");
	CL_Font_System system_font(donkeyKongContext, font_desc);
	system_font.draw_text(donkeyKongContext, 20, 30, out.str());
}

SpriteDonkeyKong::~SpriteDonkeyKong()
{	
	for each(CL_Sprite* s in donkeyKongSprites){
		if(s!=NULL){
			delete s;
			s=NULL;
		}
		
	}
	for each(CL_ResourceManager* rs in donkeyKongResources){
		if(rs!=NULL){
			delete rs;
			rs=NULL;
		}
		
	}
}